import request from '@/utils/request'

// 获取three所有树
export function getThreeList() {
  return request({
    url: '/v1/sysPermission/getTree',
    method: 'POST'
  })
}

// 获取当前用户three所有树
export function getUserMenu() {
  return request({
    url: '/v1/sysPermission/getUserMenu',
    method: 'POST'
  })
}

/** ****************************参数管理*******************************************/
export function getParameterList(data) {
  return request({
    url: '/v1/sysParam?current=' + data.current + '&size=' + data.size,
    method: 'GET'
  })
}

export function addParameterList(data) {
  return request({
    url: '/v1/sysParam',
    method: 'POST',
    data: data
  })
}

export function editorParameterList(data) {
  return request({
    url: '/v1/sysParam',
    method: 'PUT',
    data: data
  })
}

export function delParameterList(data) {
  return request({
    url: '/v1/sysParam',
    method: 'DELETE',
    data: data
  })
}

/** ****************************权限管理*******************************************/
export function getPermissionsList(data) {
  return request({
    url: '/v1/sysPermission?current=' + data.current + '&size=' + data.size,
    method: 'GET'
  })
}

export function searchPermissionsList(data) {
  return request({
    url: '/v1/sysPermission?current=' + data.current + '&size=' + data.size + '&moduleName=' + data.moduleName,
    method: 'GET'
  })
}

export function addPermissionsList(data) {
  return request({
    url: '/v1/sysPermission',
    method: 'POST',
    data: data
  })
}

export function editorPermissionsList(data) {
  return request({
    url: '/v1/sysPermission',
    method: 'PUT',
    data: data
  })
}

export function delPermissionsList(data) {
  return request({
    url: '/v1/sysPermission',
    method: 'DELETE',
    data: data
  })
}

/** ****************************用户管理*******************************************/
export function getUserList(data) {
  return request({
    url: '/v1/sysUser?current=' + data.current + '&size=' + data.size,
    method: 'GET'
  })
}

export function searchUserList(data) {
  return request({
    url: '/v1/sysUser?current=' + data.current + '&size=' + data.size + '&realName=' + data.userName + '&shopName=' + data.shopName,
    method: 'GET'
  })
}

export function addUserList(data) {
  return request({
    url: '/v1/sysUser',
    method: 'POST',
    data: data
  })
}

export function editorUserList(data) {
  return request({
    url: '/v1/sysUser',
    method: 'PUT',
    data: data
  })
}

export function delUserList(data) {
  return request({
    url: '/v1/sysUser',
    method: 'DELETE',
    data: data
  })
}

export function selectOneById() {
  return request({
    url: '/v1/sysShop/selectOneByUser',
    method: 'GET'
  })
}
export function searchShopNameByUserId(data) {
  return request({
    // + '&userId=' + data.userId
    url: '/v1/sysUser/shopNames' + '?userId=' + data.userId,
    method: 'GET'
  })
}

/** ****************************角色管理*******************************************/
export function getRoleList(data) {
  return request({
    url: '/v1/sysRole?current=' + data.current + '&size=' + data.size,
    method: 'GET'
  })
}

export function searchRoleList(data) {
  return request({
    url: '/v1/sysRole?current=' + data.current + '&size=' + data.size + '&name=' + data.name,
    method: 'GET'
  })
}

export function addRoleList(data) {
  return request({
    url: '/v1/sysRole',
    method: 'POST',
    data: data
  })
}

export function editorRoleList(data) {
  return request({
    url: '/v1/sysRole',
    method: 'PUT',
    data: data
  })
}

export function delRoleList(data) {
  return request({
    url: '/v1/sysRole',
    method: 'DELETE',
    data: data
  })
}

// 反显菜单树匹配
export function getThreeCheckeList(data) {
  return request({
    url: '/v1/sysPermission/menuMarkTree',
    method: 'POST',
    data: data
  })
}

/** ****************************定时任务管理*******************************************/
export function getTimedtaskList(data) {
  return request({
    url: '/v1/taskJob?current=' + data.current + '&size=' + data.size,
    method: 'GET'
  })
}

export function addTimedtaskList(data) {
  return request({
    url: '/v1/taskJob',
    method: 'POST',
    data: data
  })
}

export function editorTimedtaskList(data) {
  return request({
    url: '/v1/taskJob',
    method: 'PUT',
    data: data
  })
}

export function delTimedtaskList(data) {
  return request({
    url: '/v1/taskJob',
    method: 'DELETE',
    data: data
  })
}

/** ****************************企业信息*******************************************/

export function getNeidByUser() {
  return request({
    url: '/v1/enterprise/getNeidByUser',
    method: 'GET'
  })
}

export function getShopLevel() {
  return request({
    url: '/v1/shopLevel/list',
    method: 'GET'
  })
}
export function getEnterpriseList(data) {
  var url = '/v1/enterprise?current=' + data.current + '&size=' + data.size
  if (data.name != null && data.name !== '') {
    url = url + '&name=' + data.name
  }
  return request({
    url: url,
    method: 'GET'
  })
}

export function searchEnterpriseList(data) {
  return request({
    url: '/v1/enterprise?current=' + data.current + '&size=' + data.size + '&realName=' + data.name,
    method: 'GET'
  })
}

export function addEnterpriseList(data) {
  return request({
    url: '/v1/enterprise/add',
    method: 'POST',
    data: data
  })
}

export function editorEnterpriseList(data) {
  return request({
    url: '/v1/enterprise/update',
    method: 'POST',
    data: data
  })
}

export function delEnterpriseList(data) {
  return request({
    url: '/v1/enterprise',
    method: 'DELETE',
    data: data
  })
}
